package day11.console.impl;

import day11.console.ConsoleCommand;
import day11.packet.request.ListGroupMembersRequestPacket;
import day11.util.IDUtil;
import io.netty.channel.Channel;

import java.util.Scanner;

/**
 * @author chenshijie
 * @date 2024/1/2 15:54
 */

public class ListGroupMembersConsoleCommand implements ConsoleCommand {
    @Override
    public void exec(Scanner sc, Channel channel) {
        ListGroupMembersRequestPacket listGroupMembersRequestPacket = new ListGroupMembersRequestPacket();

        System.out.println("输入群号，获取群成员列表: ");
        String groupId = sc.nextLine();
        if (!IDUtil.isNumeric(groupId)) {
            System.err.println("格式错误");
        } else {
            listGroupMembersRequestPacket.setGroupId(Integer.parseInt(groupId));
            channel.writeAndFlush(listGroupMembersRequestPacket);
        }
    }
}
